package org.zjt.weather.demo;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * DESC
 *
 * @author
 * @create 2017-05-23 下午2:16
 **/
public class WeatherSort extends WritableComparator {

    public WeatherSort() {
        super(WeatherKey.class, true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        WeatherKey a1 = (WeatherKey) a;
        WeatherKey a2 = (WeatherKey) b;
        Integer var1 = Integer.compare(a1.getYear(), a2.getYear());
        if (var1 != 0)
            return var1;
        int var2 = Integer.compare(a1.getMonth(), a2.getMonth());
        if (var2 != 0)
            return var1;
        return Double.compare(a1.getHot(), a2.getHot());
    }
}
